import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项
import echarts from "@/components/machineNetworkManage/pressDataMonitor/echarts.vue"; //弹框form
import customDialog from "@/components/commonPublic/processVideo/index.vue"; //弹框form

import {
    getTestMortarFlexuraltestByFid, //详情
} from "@/api/testMonitorManage/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "tableTitle",
        "flagNum",
        "keyType"
    ],
    // 
    data() {
        return {
            visible: "",
            loading:false,
             // 过程视频弹框
             processVideoRow: {},
             processVideoShow: false,
             formDataVideo:null,
            title: null,
            isLock: false,
            dialogHeight: null,
            activeIndex: "1",
            formObj: formJs.formObj,
            currntData: null,
            dataInfo: null,
            startDates: null,
            treeData: [], //材料种类
            currentDetail: null,
            tableObj: [{
                lable: "样品/见证编号",
                value: "fSamplenostr",
                key:"",
                row: "50%"
            },
            {
                lable: "试验日期",
                value: "fTestdates",
                key:"",
                row: "50%"
            },
            {
                lable: "强度等级",
                value: "fStrength",
                key:"",
                row: "50%"
            },
            {
                lable: "龄期(d)",
                value: "fAge",
                key:"",
                row: "50%"
            },
            {
                lable: "试验尺寸",
                value: "fSpecimensize",
                key:"",
                row: "50%"
            },
            {
                lable: "",
                value: "",
                key:"",
                row: "50%"
            },
            {
                lable: "工程部位及用途",
                value: "fProjectlocation",
                key:"",
                row: "100%"
            },


        ],
            tableData: [{
                lable: "试件编号",
                value: "fTestid",
                key:"",
                row: "33%"
            },{
                lable: "荷载(kN)",
                value: "fKlhz",
                key:"",
                row: "33%"
            },{
                lable: "强度(MPa)",
                value: "fKlqd",
                key:"",
                row: "33%"
            }],
            echartsData:null,
            formData:null
        };
    },
    components: {
        publicForm,
        echarts,
        customDialog
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    console.log();
                }
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    if (this.statusNum != 1) {
                        this.getDetail(
                            this.currentDetail.fId
                        )
                    } // currentRow
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("monitorBack-userInfo"));


        if (this.statusNum == 7) { //查看

        }
        this.getHeight();
    },
    methods: {
        processVideoClose() {
            this.processVideoShow = false;
        },
        // processVideo() {
        //     this.processVideoShow = true
        // },
        processVideo() {
            // window.open(this.formDataVideo.fVideo, '_blank')
            this.processVideoShow = true
        },
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 1 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },


        // 详情
        getDetail(id) {
            this.loading=true;
            getTestMortarFlexuraltestByFid({fId:id,keyType:this.keyType}).then((res) => {
                if (res.errcode == 0) {
                    this.loading=false;
                    var data = res.data.yjQmpTestCementflexural
                    this.tableObj.map(item=>{
                        var name=item.value
                      item['key'] = data[name]
                    })
                    this.echartsData=res.data.yjQmpTestRebarjointtestitems
                    this.formDataVideo=res.data.yjQmpTestCementflexural

                    // yjQmpTestHntflexuralitems
                    this.formData=res.data
                    this.echartsData=res.data.yjQmpTestCementflexuralitems

                }else {
                    this.loading=false;
                    this.$message.error(res.msg);
                }
            });
        },


    },
};